x
(data_unused, event: MouseEvent) {module teapo {​ /** * File list/tree ViewModel. */ export class FileList {​ /** * Top level folders. */ folders = ko.observableArray<FolderEntry>();​ /** * Files directly in the root folder. */ files = ko.observableArray<FileEntry>();​ /** * Currently selected file. Should not be modified externally. */ selectedFile = ko.observable<FileEntry>(null);​ private _filesByFullPath: { [fullPath: string]: FileEntry; } = {};​ constructor(private _storage: DocumentStorage) { var fileNames = this._storage.documentNames(); for (var i = 0; i < fileNames.length; i++) {​ if (fileNames[i].charAt(0) !== '/') continue; // ignore hidden files​ this._addFileEntry(fileNames[i]); } }​ /** * Find a file from its path. */ getFileEntry(fullPath: string): FileEntry { if (fullPath.charAt(0) !== '/') return null; // ignore hidden files​ return this._filesByFullPath[fullPath]; }​ /** * Create a file entry (throwing an exception if one already exists). * Note that only the list/tree structures are created, * not touching editor nor persistence part of cocerns. */ createFileEntry(fullPath: string): FileEntry { return this._addFileEntry(fullPath); }